package com.wyc.service.impl;

import com.wyc.dao.AdminAnnMgMapper;
import com.wyc.pojo.AdminAnnMg;
import com.wyc.pojo.Allusers;
import com.wyc.service.AdminAnnMgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName AdminAnnMgServiceImp
 * @Author 王韫琛
 * @Date 2021/1/28 3:54
 * @Version 1.0
 */
@Service
public class AdminAnnMgServiceImp implements AdminAnnMgService {
    @Autowired
    private AdminAnnMgMapper adminAnnMgMapper;
    //超级管理员添加公告
    public int addAnnMg(AdminAnnMg adminAnnMg) {
        return adminAnnMgMapper.addAnnMg(adminAnnMg);
    }
    //获取超级管理员数据库添加公告的信息
    @Override
    public int getTotal(String grade) {
        return adminAnnMgMapper.getTotal(grade);
    }
    //超级管理员查询公告信息分页展示
    @Override
    public List<AdminAnnMg> findPage(Integer pageNum, Integer pageSize, String grade) {
        pageNum = (pageNum-1)*pageSize;
        List<AdminAnnMg> list = adminAnnMgMapper.findPage(pageNum, pageSize,grade);
        return list;
    }
    //超级管理员删除公告
    @Override
    public int deleteById(Integer id) {
        return adminAnnMgMapper.deleteById(id);
    }
    @Override
    public int updateById(AdminAnnMg adminAnnMg) {
        return adminAnnMgMapper.updateById(adminAnnMg);
    }

    //根据发布者姓名搜索所发布得信息
    @Override
    public List<AdminAnnMg> findPageByAuthor(Integer pageNum, Integer pageSize, String author,String grade) {
        pageNum = (pageNum-1)*pageSize;
        List<AdminAnnMg> list = adminAnnMgMapper.findPageByAuthor(pageNum, pageSize, author,grade);
        return list;
    }
    //根据发布者姓名获取数据所发布的所有信息总和
    @Override
    public int getTotalByAuthor(String author,String grade) {
        return adminAnnMgMapper.getTotalByAuthor(author,grade);
    }


}

